Bs.ui.Container = function (props) {
	Bs.ui.Container.superclass.constructor.call (this, props);
};
Lang.extend (Bs.ui.Container, Bs.ui.Component, {
	// protected
	doPaint: function () {
		// process children
		if (Bs.ui.Container.superclass.doPaint.apply (this) === false) {
			return false;
		}
		Lang.loop (this.children, function (c, i) {
			this.fireAdd (i, c);
		}, this);
		return true;
	},
	get: function (index) {
		return this.children[index];
	},
	remove: function (o, kill) {
		if (Lang.isNumber (o)) {
			if (this.children.length > o) {
				var c = this.get (o);
				this.children.removeRange (o);
				this.fireRemove (c, kill);
			}
		} else if (Lang.isObject (o)) {
			var index = this.children.remove (o);
			if (index >= 0) {
				this.fireRemove (o, kill);
			}
		}
	}, 
	add: function (child) {
		if (!child) {
			return;
		}
		if (!this.children) {
			this.children = [];
		}
		if (Lang.isObject(child)) {
			this.children.push (child);
			return this.fireAdd (this.children.length - 1, child);
		} else if (Lang.isArray(child)) {
			for (var i = 0; i < child.length; i++) {
				this.add (child [i]);
			}
		} else if (Lang.isString (child)) {
			return this.fireAdd (this.children.length - 1, child);
		} 
	}, 
	// private
	fireRemove: function (c, kill) {
		if (c.he) {
			this.he.removeChild (c.he);
		}
		if (kill == undefined || kill === true) {
			delete c.he;
		}
	}, 
	// private
	fireAdd: function (index, c) {
		if (!c) {
			return;
		}
		if (Lang.isString (c)) {
			c = this.addString (c);
		}
		if (!c.paint) {
			c = Device.getWidget (c);
			this.children [index]=c;
		}
		if (!c.painted) {
			c.paint ();
		}
		this.he.appendChild (c.he);
		return this.get (index);
	},
	// private
	addString: function (s) {
		return {spec: s};
	}
});
Device.addWidget('Container', Bs.ui.Container);